var http = require('http');
var querystring = require('querystring');
var formData = querystring.stringify({
    "qnrId": "g5JbxBp7JB",
    "qnrRecId": "pZfZh4UUswPT",
    "recList": [{
        "quId": "g5JbxBp7JB5",
        "aswrId": "g5JbxBp7JB6",
        "custFillAswrCntt": "皮个毛线啊"
    }],
    "smsCode": "",
    "pwd": "",
    "place": "ngqss",
    "code": "",
    "snapshotCommit": [{
        "quId": "g5JbxBp7JB5"
    }],
    "outsd": {
        "chnl": "ngqss",
        "answerLang": "zh-CN"
    }
});
var optins = {
    hostname: 'ywj.10085.cn',
    port: 80,
    path: '/front/sh/NGAnswer!submit?uid=post',
    method: 'POST',
    headers: {
        "Accept": "application/json, text/javascript, */*; q=0.01",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
        "Connection": "keep-alive",
        "Content-Length": formData.length,
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Cookie": "name=value; RID=9864bb3b-9539-4ecf-8977-cea0d7c43796; ngqsssessionid=3b9df60e-5e03-4f83-9a91-123f4692f439; i18next=zh-CN; i18nAnswer=zh-CN",
        "DNT": "1",
        "Host": "ywj.10085.cn",
        "Origin": "http://ywj.10085.cn",
        "Referer": "http://ywj.10085.cn/answer.html?qnrId=g5JbxBp7JB&chnl=ngqss&answerLang=zh-CN",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36",
        "X-Requested-With": "XMLHttpRequest"
    }
};

var req = http.request(optins, function (res) {
    res.on('data', function (chunk) {
        console.log(Buffer.isBuffer(chunk))
    });

    res.on('end', function () {
        console.log('提交问卷成功！')
    });

});
req.on('error', function (e) {
    console.log('提交问卷失败' + e.message);
})
req.write(formData);
req.end();